<template>
  <el-form :model="formData" style="width: 100%; height: 100%">
    <basic-editor style="height: 100%" v-model="formData.fileContent"></basic-editor>
  </el-form>
</template>
<script setup lang="ts">
import { getTemplateFile } from '@/api/gen/template-file';
import BasicEditor from '@/components/code-editor/basic-editor/index.vue';
import { onMounted, ref } from 'vue';
import type { ITemplateFile } from '../template-set';
defineOptions({
  name: 'TemplateFileForm',
});
const props = defineProps({
  id: {
    type: String,
    required: true,
  },
});

const formData = ref<ITemplateFile>({
  id: props.id,
  fileName: '',
  fileContent: '',
  parentId: '',
  setId: '',
  directory: 0,
});
onMounted(() => {
  const id = props.id;
  getTemplateFile(id).then((res) => {
    formData.value = res.data as unknown as ITemplateFile;
  });
});
const save = () => {
  alert(JSON.stringify(formData.value));
};
defineExpose({ save });
</script>
